home *** CD-ROM | disk | FTP | other *** search
- package mx.core
- {
- import flash.display.DisplayObject;
- import flash.display.DisplayObjectContainer;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.system.ApplicationDomain;
- import flash.text.TextFormat;
- import flash.text.TextLineMetrics;
- import flash.utils.getQualifiedClassName;
- import mx.automation.IAutomationObject;
- import mx.managers.ISystemManager;
- import mx.managers.IToolTipManagerClient;
- import mx.managers.SystemManager;
- import mx.managers.ToolTipManager;
- import mx.resources.ResourceBundle;
- import mx.styles.ISimpleStyleClient;
- import mx.styles.IStyleClient;
- import mx.styles.StyleManager;
- import mx.styles.StyleProtoChain;
- import mx.utils.StringUtil;
-
- use namespace mx_internal;
-
- public class UITextField extends FlexTextField implements IAutomationObject, IIMESupport, IFlexModule, IInvalidating, ISimpleStyleClient, IToolTipManagerClient, IUIComponent
- {
- private static var resourceTruncationIndicator:String;
-
- mx_internal static const VERSION:String = "2.0.1.0";
-
- private static var packageResources:ResourceBundle = ResourceBundle.getResourceBundle("core",ApplicationDomain.currentDomain);
-
- mx_internal static const TEXT_WIDTH_PADDING:int = 5;
-
- mx_internal static const TEXT_HEIGHT_PADDING:int = 4;
-
- loadResources();
-
- private var _initialized:Boolean = false;
-
- private var invalidateDisplayListFlag:Boolean = true;
-
- mx_internal var explicitColor:uint = 4294967295;
-
- private var _processedDescriptors:Boolean = true;
-
- private var explicitHTMLText:String = null;
-
- private var _owner:DisplayObjectContainer;
-
- mx_internal var _parent:DisplayObjectContainer;
-
- mx_internal var styleChangedFlag:Boolean = true;
-
- private var _explicitWidth:Number;
-
- private var _enabled:Boolean = true;
-
- private var cachedTextFormat:TextFormat;
-
- private var _automationDelegate:IAutomationObject;
-
- private var _automationName:String;
-
- private var _document:Object;
-
- private var _styleName:Object;
-
- private var _nestLevel:int = 0;
-
- private var _explicitHeight:Number;
-
- private var _toolTip:String;
-
- private var _nonInheritingStyles:Object;
-
- private var _moduleFactory:IFlexModuleFactory;
-
- private var _inheritingStyles:Object;
-
- private var _includeInLayout:Boolean = true;
-
- private var _updateCompletePendingFlag:Boolean = false;
-
- private var _imeMode:String = null;
-
- private var _ignorePadding:Boolean = true;
-
- public function UITextField()
- {
- invalidateDisplayListFlag = true;
- mx_internal::styleChangedFlag = true;
- explicitHTMLText = null;
- mx_internal::explicitColor = StyleManager.NOT_A_COLOR;
- _enabled = true;
- _ignorePadding = true;
- _imeMode = null;
- _includeInLayout = true;
- _inheritingStyles = UIComponent.mx_internal::STYLE_UNINITIALIZED;
- _initialized = false;
- _nestLevel = 0;
- _nonInheritingStyles = UIComponent.mx_internal::STYLE_UNINITIALIZED;
- _processedDescriptors = true;
- _updateCompletePendingFlag = false;
- super();
- focusRect = false;
- selectable = false;
- tabEnabled = false;
- addEventListener(Event.CHANGE,changeHandler);
- addEventListener("textFieldStyleChange",textFieldStyleChangeHandler);
- }
-
- private static function loadResources() : void
- {
- resourceTruncationIndicator = packageResources.getString("truncationIndicator");
- }
-
- public function get nestLevel() : int
- {
- return _nestLevel;
- }
-
- public function set nestLevel(param1:int) : void
- {
- if(param1 > 1 && _nestLevel != param1)
- {
- _nestLevel = param1;
- StyleProtoChain.initTextField(this);
- mx_internal::styleChangedFlag = true;
- validateNow();
- }
- }
-
- public function getExplicitOrMeasuredHeight() : Number
- {
- return !isNaN(explicitHeight) ? explicitHeight : measuredHeight;
- }
-
- public function get className() : String
- {
- var _loc1_:String = null;
- var _loc2_:int = 0;
- _loc1_ = getQualifiedClassName(this);
- _loc2_ = int(_loc1_.indexOf("::"));
- if(_loc2_ != -1)
- {
- _loc1_ = _loc1_.substr(_loc2_ + 2);
- }
- return _loc1_;
- }
-
- public function setColor(param1:uint) : void
- {
- mx_internal::explicitColor = param1;
- mx_internal::styleChangedFlag = true;
- invalidateDisplayListFlag = true;
- validateNow();
- }
-
- public function get automationName() : String
- {
- if(_automationName)
- {
- return _automationName;
- }
- if(automationDelegate)
- {
- return automationDelegate.automationName;
- }
- return "";
- }
-
- private function creatingSystemManager() : ISystemManager
- {
- return moduleFactory != null && moduleFactory is ISystemManager ? ISystemManager(moduleFactory) : systemManager;
- }
-
- public function set tweeningProperties(param1:Array) : void
- {
- }
-
- public function invalidateDisplayList() : void
- {
- invalidateDisplayListFlag = true;
- }
-
- public function get focusPane() : Sprite
- {
- return null;
- }
-
- public function getExplicitOrMeasuredWidth() : Number
- {
- return !isNaN(explicitWidth) ? explicitWidth : measuredWidth;
- }
-
- public function getTextStyles() : TextFormat
- {
- var _loc1_:TextFormat = null;
- _loc1_ = new TextFormat();
- _loc1_.align = getStyle("textAlign");
- _loc1_.bold = getStyle("fontWeight") == "bold";
- if(enabled)
- {
- if(mx_internal::explicitColor == StyleManager.NOT_A_COLOR)
- {
- _loc1_.color = getStyle("color");
- }
- else
- {
- _loc1_.color = mx_internal::explicitColor;
- }
- }
- else
- {
- _loc1_.color = getStyle("disabledColor");
- }
- _loc1_.font = StringUtil.trimArrayElements(getStyle("fontFamily"),",");
- _loc1_.indent = getStyle("textIndent");
- _loc1_.italic = getStyle("fontStyle") == "italic";
- _loc1_.kerning = getStyle("kerning");
- _loc1_.leading = getStyle("leading");
- _loc1_.leftMargin = ignorePadding ? 0 : getStyle("paddingLeft");
- _loc1_.letterSpacing = getStyle("letterSpacing");
- _loc1_.rightMargin = ignorePadding ? 0 : getStyle("paddingRight");
- _loc1_.size = getStyle("fontSize");
- _loc1_.underline = getStyle("textDecoration") == "underline";
- cachedTextFormat = _loc1_;
- return _loc1_;
- }
-
- public function get explicitHeight() : Number
- {
- return _explicitHeight;
- }
-
- public function set automationName(param1:String) : void
- {
- _automationName = param1;
- }
-
- public function get percentWidth() : Number
- {
- return NaN;
- }
-
- public function createAutomationIDPart(param1:IAutomationObject) : Object
- {
- return null;
- }
-
- override public function get parent() : DisplayObjectContainer
- {
- return !!mx_internal::_parent ? mx_internal::_parent : super.parent;
- }
-
- public function setActualSize(param1:Number, param2:Number) : void
- {
- if(width != param1)
- {
- width = param1;
- }
- if(height != param2)
- {
- height = param2;
- }
- }
-
- public function set focusPane(param1:Sprite) : void
- {
- }
-
- public function getAutomationChildAt(param1:int) : IAutomationObject
- {
- return null;
- }
-
- public function get inheritingStyles() : Object
- {
- return _inheritingStyles;
- }
-
- public function invalidateProperties() : void
- {
- }
-
- public function get explicitMinWidth() : Number
- {
- return NaN;
- }
-
- public function set explicitHeight(param1:Number) : void
- {
- _explicitHeight = param1;
- }
-
- public function set showInAutomationHierarchy(param1:Boolean) : void
- {
- }
-
- public function set systemManager(param1:ISystemManager) : void
- {
- }
-
- public function get moduleFactory() : IFlexModuleFactory
- {
- return _moduleFactory;
- }
-
- public function set percentWidth(param1:Number) : void
- {
- }
-
- public function get imeMode() : String
- {
- return _imeMode;
- }
-
- public function get document() : Object
- {
- return _document;
- }
-
- public function get explicitMaxWidth() : Number
- {
- return NaN;
- }
-
- public function replayAutomatableEvent(param1:Event) : Boolean
- {
- if(automationDelegate)
- {
- return automationDelegate.replayAutomatableEvent(param1);
- }
- return false;
- }
-
- public function set owner(param1:DisplayObjectContainer) : void
- {
- _owner = param1;
- }
-
- public function set processedDescriptors(param1:Boolean) : void
- {
- _processedDescriptors = param1;
- }
-
- public function get includeInLayout() : Boolean
- {
- return _includeInLayout;
- }
-
- private function changeHandler(param1:Event) : void
- {
- explicitHTMLText = null;
- }
-
- override public function setTextFormat(param1:TextFormat, param2:int = -1, param3:int = -1) : void
- {
- if(styleSheet)
- {
- return;
- }
- super.setTextFormat(param1,param2,param3);
- dispatchEvent(new Event("textFormatChange"));
- }
-
- public function resolveAutomationIDPart(param1:Object) : Array
- {
- return [];
- }
-
- public function set inheritingStyles(param1:Object) : void
- {
- _inheritingStyles = param1;
- }
-
- public function setFocus() : void
- {
- systemManager.stage.focus = this;
- }
-
- public function set initialized(param1:Boolean) : void
- {
- _initialized = param1;
- }
-
- public function owns(param1:DisplayObject) : Boolean
- {
- return param1 == this;
- }
-
- public function setVisible(param1:Boolean, param2:Boolean = false) : void
- {
- this.visible = param1;
- }
-
- public function get nonInheritingStyles() : Object
- {
- return _nonInheritingStyles;
- }
-
- public function get isPopUp() : Boolean
- {
- return false;
- }
-
- public function get percentHeight() : Number
- {
- return NaN;
- }
-
- public function truncateToFit(param1:String = null) : Boolean
- {
- var _loc2_:String = null;
- var _loc3_:Number = NaN;
- var _loc4_:String = null;
- if(!param1)
- {
- param1 = resourceTruncationIndicator;
- }
- validateNow();
- _loc2_ = super.text;
- _loc3_ = width;
- if(_loc2_ != "" && textWidth + mx_internal::TEXT_WIDTH_PADDING > _loc3_)
- {
- _loc4_ = super.text = _loc2_;
- _loc2_.slice(0,Math.floor(_loc3_ / (textWidth + mx_internal::TEXT_WIDTH_PADDING) * _loc2_.length));
- while(_loc4_.length > 1 && textWidth + mx_internal::TEXT_WIDTH_PADDING > _loc3_)
- {
- _loc4_ = _loc4_.slice(0,-1);
- super.text = _loc4_ + param1;
- }
- return true;
- }
- return false;
- }
-
- public function validateNow() : void
- {
- var _loc1_:TextFormat = null;
- var _loc2_:ISystemManager = null;
- if(!parent)
- {
- return;
- }
- if(!isNaN(explicitWidth) && super.width != explicitWidth)
- {
- super.width = explicitWidth > 4 ? explicitWidth : 4;
- }
- if(!isNaN(explicitHeight) && super.height != explicitHeight)
- {
- super.height = explicitHeight;
- }
- if(mx_internal::styleChangedFlag)
- {
- _loc1_ = getTextStyles();
- _loc2_ = creatingSystemManager();
- embedFonts = !!_loc1_.font ? _loc2_ != null && _loc2_.isFontFaceEmbedded(_loc1_) : getStyle("embedFonts");
- antiAliasType = getStyle("fontAntiAliasType");
- gridFitType = getStyle("fontGridFitType");
- sharpness = getStyle("fontSharpness");
- thickness = getStyle("fontThickness");
- if(!styleSheet)
- {
- super.setTextFormat(_loc1_);
- defaultTextFormat = _loc1_;
- }
- dispatchEvent(new Event("textFieldStyleChange"));
- }
- mx_internal::styleChangedFlag = false;
- invalidateDisplayListFlag = false;
- }
-
- public function get ignorePadding() : Boolean
- {
- return _ignorePadding;
- }
-
- public function get automationTabularData() : Object
- {
- return null;
- }
-
- private function textFieldStyleChangeHandler(param1:Event) : void
- {
- if(explicitHTMLText != null)
- {
- super.htmlText = explicitHTMLText;
- }
- }
-
- public function set moduleFactory(param1:IFlexModuleFactory) : void
- {
- _moduleFactory = param1;
- }
-
- public function set imeMode(param1:String) : void
- {
- _imeMode = param1;
- }
-
- public function get measuredMinHeight() : Number
- {
- return 0;
- }
-
- public function get minHeight() : Number
- {
- return 0;
- }
-
- public function get tweeningProperties() : Array
- {
- return null;
- }
-
- public function set document(param1:Object) : void
- {
- _document = param1;
- }
-
- public function set updateCompletePendingFlag(param1:Boolean) : void
- {
- _updateCompletePendingFlag = param1;
- }
-
- public function get explicitMinHeight() : Number
- {
- return NaN;
- }
-
- override public function set text(param1:String) : void
- {
- if(!param1)
- {
- param1 = "";
- }
- if(!isHTML && super.text == param1)
- {
- return;
- }
- super.text = param1;
- explicitHTMLText = null;
- if(invalidateDisplayListFlag)
- {
- validateNow();
- }
- }
-
- public function get numAutomationChildren() : int
- {
- return 0;
- }
-
- public function setStyle(param1:String, param2:*) : void
- {
- }
-
- public function get showInAutomationHierarchy() : Boolean
- {
- return true;
- }
-
- public function get systemManager() : ISystemManager
- {
- var _loc1_:DisplayObject = null;
- var _loc2_:IUIComponent = null;
- _loc1_ = parent;
- while(_loc1_)
- {
- _loc2_ = _loc1_ as IUIComponent;
- if(_loc2_)
- {
- return _loc2_.systemManager;
- }
- _loc1_ = _loc1_.parent;
- }
- return null;
- }
-
- public function get baselinePosition() : Number
- {
- var _loc1_:TextLineMetrics = null;
- _loc1_ = getLineMetrics(0);
- return height - 4 - _loc1_.descent;
- }
-
- public function set enabled(param1:Boolean) : void
- {
- mouseEnabled = param1;
- _enabled = param1;
- styleChanged("color");
- }
-
- public function get minWidth() : Number
- {
- return 0;
- }
-
- public function get automationValue() : Array
- {
- if(automationDelegate)
- {
- return automationDelegate.automationValue;
- }
- return [""];
- }
-
- public function get measuredWidth() : Number
- {
- validateNow();
- return textWidth + mx_internal::TEXT_WIDTH_PADDING;
- }
-
- public function parentChanged(param1:DisplayObjectContainer) : void
- {
- if(!param1)
- {
- mx_internal::_parent = null;
- _nestLevel = 0;
- }
- else if(param1 is IStyleClient)
- {
- mx_internal::_parent = param1;
- }
- else if(param1 is SystemManager)
- {
- mx_internal::_parent = param1;
- }
- else
- {
- mx_internal::_parent = param1.parent;
- }
- }
-
- public function get processedDescriptors() : Boolean
- {
- return _processedDescriptors;
- }
-
- public function get owner() : DisplayObjectContainer
- {
- return !!_owner ? _owner : parent;
- }
-
- public function get maxWidth() : Number
- {
- return UIComponent.DEFAULT_MAX_WIDTH;
- }
-
- public function get initialized() : Boolean
- {
- return _initialized;
- }
-
- public function set includeInLayout(param1:Boolean) : void
- {
- var _loc2_:IInvalidating = null;
- if(_includeInLayout != param1)
- {
- _includeInLayout = param1;
- _loc2_ = parent as IInvalidating;
- if(_loc2_)
- {
- _loc2_.invalidateSize();
- _loc2_.invalidateDisplayList();
- }
- }
- }
-
- override public function set htmlText(param1:String) : void
- {
- if(!param1)
- {
- param1 = "";
- }
- if(isHTML && super.htmlText == param1)
- {
- return;
- }
- if(Boolean(cachedTextFormat) && styleSheet == null)
- {
- defaultTextFormat = cachedTextFormat;
- }
- super.htmlText = param1;
- explicitHTMLText = param1;
- if(invalidateDisplayListFlag)
- {
- validateNow();
- }
- }
-
- public function set measuredMinWidth(param1:Number) : void
- {
- }
-
- public function get updateCompletePendingFlag() : Boolean
- {
- return _updateCompletePendingFlag;
- }
-
- public function get enabled() : Boolean
- {
- return _enabled;
- }
-
- public function set nonInheritingStyles(param1:Object) : void
- {
- _nonInheritingStyles = param1;
- }
-
- public function set automationDelegate(param1:Object) : void
- {
- _automationDelegate = param1 as IAutomationObject;
- }
-
- public function get measuredMinWidth() : Number
- {
- return 0;
- }
-
- public function set isPopUp(param1:Boolean) : void
- {
- }
-
- public function get measuredHeight() : Number
- {
- validateNow();
- return textHeight + mx_internal::TEXT_HEIGHT_PADDING;
- }
-
- public function getUITextFormat() : UITextFormat
- {
- var _loc1_:UITextFormat = null;
- validateNow();
- _loc1_ = new UITextFormat(creatingSystemManager());
- _loc1_.mx_internal::copyFrom(getTextFormat());
- _loc1_.antiAliasType = antiAliasType;
- _loc1_.gridFitType = gridFitType;
- _loc1_.sharpness = sharpness;
- _loc1_.thickness = thickness;
- return _loc1_;
- }
-
- public function initialize() : void
- {
- }
-
- public function set percentHeight(param1:Number) : void
- {
- }
-
- public function get maxHeight() : Number
- {
- return UIComponent.DEFAULT_MAX_HEIGHT;
- }
-
- public function set styleName(param1:Object) : void
- {
- if(_styleName === param1)
- {
- return;
- }
- _styleName = param1;
- if(parent)
- {
- StyleProtoChain.initTextField(this);
- styleChanged("styleName");
- }
- }
-
- public function get automationDelegate() : Object
- {
- return _automationDelegate;
- }
-
- public function set ignorePadding(param1:Boolean) : void
- {
- _ignorePadding = param1;
- styleChanged(null);
- }
-
- public function set toolTip(param1:String) : void
- {
- ToolTipManager.mx_internal::registerToolTip(this,param1);
- _toolTip = param1;
- }
-
- public function styleChanged(param1:String) : void
- {
- mx_internal::styleChangedFlag = true;
- if(!invalidateDisplayListFlag)
- {
- invalidateDisplayListFlag = true;
- UIComponent(parent).callLater(validateNow);
- }
- }
-
- private function get isHTML() : Boolean
- {
- return explicitHTMLText != null;
- }
-
- public function get explicitMaxHeight() : Number
- {
- return NaN;
- }
-
- public function invalidateSize() : void
- {
- invalidateDisplayListFlag = true;
- }
-
- public function set explicitWidth(param1:Number) : void
- {
- _explicitWidth = param1;
- }
-
- public function move(param1:Number, param2:Number) : void
- {
- if(this.x != param1)
- {
- this.x = param1;
- }
- if(this.y != param2)
- {
- this.y = param2;
- }
- }
-
- public function get toolTip() : String
- {
- return _toolTip;
- }
-
- public function set measuredMinHeight(param1:Number) : void
- {
- }
-
- public function get explicitWidth() : Number
- {
- return _explicitWidth;
- }
-
- public function getStyle(param1:String) : *
- {
- if(StyleManager.mx_internal::inheritingStyles[param1])
- {
- return !!inheritingStyles ? inheritingStyles[param1] : IStyleClient(parent).getStyle(param1);
- }
- return !!nonInheritingStyles ? nonInheritingStyles[param1] : IStyleClient(parent).getStyle(param1);
- }
-
- public function get styleName() : Object
- {
- return _styleName;
- }
- }
- }
-
-